package com.kernelstudio.framework.compatible.supports.liquibase.database;
/*
 * This file is part of the kernelstudio package.
 *
 * (c) 2014-2024 zlin <admin@kernelstudio.com>
 *
 * For the full copyright and license information, please view the LICENSE file
 * that was distributed with this source code.
 */

import liquibase.database.core.OracleDatabase;

/**
 * 适配人大金仓数据库
 */
public class KingBase8OracleDatabase extends OracleDatabase {

    public static final String PRODUCT_NAME = "KingbaseES";

    public static final String SHORT_NAME = "kingbase8";

    private static final int DEFAULT_TCP_PORT_NUMBER = 54321;

    @Override
    public String getShortName() {
        return SHORT_NAME;
    }

    @Override
    protected String getDefaultDatabaseProductName() {
        return PRODUCT_NAME;
    }

    @Override
    public Integer getDefaultPort() {
        return DEFAULT_TCP_PORT_NUMBER;
    }

    @Override
    public String getDefaultDriver(String url) {
        if (url.startsWith("jdbc:kingbase8:")) {
            return "com.kingbase8.Driver";
        }
        return null;
    }

    /**
     * Should the database use "serial" datatypes vs. "generated by default as identity"
     */
    public boolean useSerialDatatypes() {
        return true;
    }

    @Override
    public int getPriority() {
        //提高优先级以便优先于liquibase自带的
        return PRIORITY_DATABASE;
    }
}
